package com.company.module.net.interceptor;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * desc :
 * user : sixbing
 * time : 2019-03-27 11:30.
 * version : 1.0
 */

public class HeaderSetInterceptor implements Interceptor {
    private static String TAG = "HeaderSetInterceptor";

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();
        /*查看原来的header*/
        Request.Builder requestBuilder = request.newBuilder()
                .header("Content-Type", "application/json")
                .header("platform", "andriod_phone")
                .header("token", haveToken())
                .header("appname", "com.immortal.jeeqin")
                .header("version", "android 2.1.2")
                .header("lang", "3123")
                .header("country", "32")
                .header("v", "1.0");

        request = requestBuilder.build();
        //Response 请求返回
        return chain.proceed(request);
    }

    /**
     * 获取token
     */
    private static String haveToken() {
//        new NullPointerException("token  set is need !");
        return "2222";
    }
}
